import {
  q as s,
  p as me,
  ap as he,
  X as U,
  f as ge,
  H as ve,
  av as $,
  aw as ye,
  k as t,
  l,
  m as a,
  ax as b,
  as as f,
  az as be,
  at as V,
  ay as De
} from "./index-b50e6ef9.js";
import { d as xe, c as q } from "./order-9978affc.js";
function g(h) {
  return (
    typeof h == "function" ||
    (Object.prototype.toString.call(h) === "[object Object]" && !De(h))
  );
}
function Be(h) {
  const D = s([]),
    M = s([]),
    L = s([]),
    H = s([]),
    z = s({}),
    m = s(!0);
  s({}), me();
  const v = s(1),
    y = s(10),
    r = s([]),
    p = s([]),
    X = s(),
    x = s(),
    F = s(),
    J = s(),
    O = s(),
    E = s(""),
    W = s(""),
    B = s(""),
    R = s(""),
    k = s("nohide"),
    G = he("reload"),
    w = U({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    K = U({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    Q = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "ID",
        prop: "order_id",
        minWidth: 80,
        formatter: ({ order_id: e }) => `1${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "地址",
        prop: "address",
        align: "left",
        minWidth: 600,
        hide: () => k.value != "hideAddress",
        formatter: ({ address: e, track_code: u }) =>
          t("div", { style: "word-break: break-all;word-wrap: break-word;" }, [
            t("div", null, [e]),
            t("div", null, [
              u
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(u) ? u : { default: () => [u] }
                  )
                : ""
            ])
          ])
      },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({
          wares_name: e,
          store_name: u,
          store_code: n,
          notes: o,
          activity: c,
          remarks: i,
          size: d
        }) =>
          t("div", null, [
            t("div", null, [e]),
            u
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  g(u) ? u : { default: () => [u] }
                )
              : "",
            n
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [a("门店码:"), n] }
                )
              : "",
            t("div", null, [
              o
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(o) ? o : { default: () => [o] }
                  )
                : ""
            ]),
            t("div", null, [
              c == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [a("已赠送")] }
                  )
                : ""
            ]),
            t("div", null, [
              i
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(i) ? i : { default: () => [i] }
                  )
                : ""
            ]),
            t("div", null, [
              d
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(d) ? d : { default: () => [d] }
                  )
                : ""
            ])
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      {
        label: "支付金额",
        prop: "pay_price",
        minWidth: 100,
        formatter: ({ pay_price: e }) =>
          t("div", { style: "color:#59AB74" }, [e])
      },
      { label: "积分折扣", prop: "hock_price", minWidth: 80 },
      { label: "折扣支付", prop: "other_price", minWidth: 80 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 80,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "积分";
          if (e == 2) return "微信";
          if (e == 3) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      {
        label: "内含数量",
        prop: "all_bottle",
        minWidth: 100,
        formatter: ({ all_bottle: e, wares_unit: u }) => e + u
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 150,
        formatter: ({ status: e, track_name: u, content: n }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && u != "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已快递")] }
              ),
              t("br", null, null),
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [n || "暂无信息"] }
              )
            ]);
          if (e == 3 && u == "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已自提")] }
              ),
              t("br", null, null),
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [n || "暂无信息"] }
              )
            ]);
        }
      },
      {
        label: "时间",
        minWidth: 200,
        prop: "add_time",
        formatter: ({ add_time: e, end_time: u }) =>
          t("div", null, [
            t("div", null, [
              a("下单："),
              b(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
            ]),
            t("div", null, [
              a("完成："),
              b(u * 1e3).format("YYYY-MM-DD HH:mm:ss")
            ])
          ])
      },
      { label: "操作", fixed: "right", width: 220, slot: "operation" }
    ],
    Z = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "phone", minWidth: 120 },
      { label: "收件人姓名", prop: "name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: u, content: n }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && u != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递("), n, a(")")] }
            );
          if (e == 3 && u == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提("), n, a(")")] }
            );
        }
      },
      { label: "内含几瓶", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => b(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      {
        label: "结束时间",
        minWidth: 180,
        prop: "end_time",
        formatter: ({ end_time: e }) => b(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "衣服规格", prop: "size", minWidth: 100 },
      { label: "订单备注", prop: "remarks", minWidth: 100 },
      { label: "备注", prop: "notes", minWidth: 100 },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    P = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("暂无")] }
            );
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星合伙人")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星合伙人")] }
            );
          if (e == 3)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星合伙人")] }
            );
          if (e == 4)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星合伙人")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("五星合伙人")] }
            );
          if (e == 6)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星联创")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星联创")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星联创")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星联创")] }
            );
          if (e == 10)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星董事")] }
            );
          if (e == 11)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星董事")] }
            );
          if (e == 12)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: u }) => e || u
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已发放")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [a("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    ee = ge(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function te(e) {
    const u = { order_id: e.order_id },
      n = JSON.stringify(u),
      c = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(n)) },
      i = await xe(c);
    i.code == 200 &&
      ((M.value = i.data.income),
      (L.value = i.data.dispel),
      (H.value = i.data.freeze),
      (z.value = i.data.indent));
  }
  async function le(e) {
    be(e);
  }
  async function ae(e) {
    const u = { id: e.id },
      n = JSON.stringify(u),
      c = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(n)) },
      i = await questionDelete(c);
    i.code == 200
      ? (V("删除成功", { type: "success" }), G())
      : V(i.msg, { type: "error" });
  }
  function ue() {}
  function se(e) {
    (y.value = e), _(void 0, e);
  }
  function ie(e) {
    (v.value = e), _(e, void 0);
  }
  function ne(e) {}
  function re(e) {
    (K.text = `正在加载第${e}页...`),
      (m.value = !0),
      $(600).then(() => {
        m.value = !1;
      });
  }
  async function de(e, u, n = [], o, c = [], i, d, A, C, S, j) {
    (r.value = []),
      (p.value = []),
      (x.value = e),
      (F.value = o),
      (O.value = d),
      (E.value = A),
      (W.value = C),
      (B.value = S),
      (R.value = j),
      n.map(Y => {
        const I = Y,
          N = new Date(I);
        r.value.push(
          N.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      c.map(Y => {
        const I = Y,
          N = new Date(I);
        p.value.push(
          N.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (m.value = !0),
      (X.value = e),
      (J.value = i);
    const ce = {
        page: v.value,
        pagesize: y.value,
        status: 3,
        user_phone: isNaN(u) ? void 0 : u,
        user_id: isNaN(i) ? void 0 : i,
        user_name: isNaN(u) ? u : void 0,
        order_code: A || void 0,
        name_phone: C || void 0,
        start: r.value[0] ? r.value[0] : p.value[0],
        end: r.value[1] ? r.value[1] : p.value[1],
        track_name: e,
        content: o,
        store_code: d,
        wares_unit: S == "no" ? void 0 : S,
        all_bottle: j || void 0,
        action: r.value[0] ? "add_time" : "end_time"
      },
      fe = JSON.stringify(ce),
      pe = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(fe)) },
      { data: T } = await q(pe);
    (D.value = T.indent.data),
      (w.total = T.indent.total),
      setTimeout(() => {
        m.value = !1;
      }, 500);
  }
  async function _(e = v.value, u = y.value) {
    const n = {
        page: e,
        pagesize: u,
        status: "3",
        start: r.value[0] ? r.value[0] : p.value[0],
        end: r.value[1] ? r.value[1] : p.value[1],
        user_id: J.value,
        track_name: x.value,
        content: F.value,
        store_code: O.value,
        order_code: E.value ? E.value : void 0,
        name_phone: W.value ? W.value : void 0,
        wares_unit: B.value == "no" ? void 0 : B.value,
        all_bottle: R.value || void 0,
        action: r.value[0] ? "add_time" : "end_time"
      },
      o = JSON.stringify(n),
      i = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(o)) },
      d = await q(i);
    d.code === 200
      ? ((D.value = d.data.indent.data),
        (w.total = d.data.indent.total),
        setTimeout(() => {
          m.value = !1;
        }, 500))
      : V(d.msg, { type: "error" });
  }
  const oe = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ve(() => {
      $().then(() => {
        const { setWatermark: e } = ye(h.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        _();
    }),
    {
      loading: m,
      columns: Q,
      dataList: D,
      userColumns: P,
      pagination: w,
      buttonClass: ee,
      userDatilList: M,
      orderInfo: z,
      columnsTable: Z,
      formattedDate: r,
      formattedDate1: p,
      typeV: x,
      userCV: F,
      count: v,
      hideVal: k,
      pageCount: y,
      userDatilListDisple: L,
      userDatilListFreeze: H,
      handleLookUserDatil: te,
      onSearch: de,
      resetForm: oe,
      handleaddUser: ue,
      handleUpdate: le,
      handleDelete: ae,
      handleSizeChange: se,
      handleCurrentChange: ie,
      handleSelectionChange: ne,
      onCurrentChange: re
    }
  );
}
export { Be as useRole };
